package com.shk.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.shk.constant.MessageConstant;
import com.shk.entity.Result;
import com.shk.pojo.Setmeal;
import com.shk.service.SetmealService;
import okhttp3.Request;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;

@RestController

@RequestMapping("/setmeal")
public class SetmealController {
    @Reference
    private SetmealService setmealService;

    @RequestMapping("/getSetmeal")

    public Result getSetmeal(){

        try {
            List<Setmeal> data = setmealService.mobileFindAll();
            return new Result(true, MessageConstant.QUERY_SETMEALLIST_SUCCESS,data);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEALLIST_FAIL);
        }
    }

    @RequestMapping("/findById")
    public Result findById(Integer id){
        try {
            Setmeal data = setmealService.findById(id);
            return new Result(true,MessageConstant.EDIT_SETMEAL_SUCCESS,data);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }

    }

    @RequestMapping("/find")
    public Result find(Integer id){
        try {
            Setmeal setmeal=setmealService.find(id);
            return new Result(true,MessageConstant.ADD_CHECKGROUP_FAIL,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.ADD_CHECKGROUP_FAIL);
        }
    }
}
